<?php


namespace App\Service\Cooperative;


use App\Dao\NoticeCooperativeDao;
use Hyperf\Di\Annotation\Inject;

class NoticeCooperService extends BaseService
{

    /**
     * @Inject()
     * @var NoticeCooperativeDao
     */
    protected $NoticeCooperativeDao;

    /**
     * 获取未读消息
     * @param $data
     * @return mixed
     */
    public function UnreadList($data)
    {
        $data['user_id'] = $this->user()->id;
        $result = $this->NoticeCooperativeDao->UnreadList($data);
        $arr = array();
        foreach ($result['data'] as $key=>$item){
            array_push($arr,$item);
        }
        $list['data'] = $arr;
        $list['total'] = $result['total'];
        $list['per_page'] = $result['per_page'];
        $list['current_page'] = $result['current_page'];
        $list['last_page'] = $result['last_page'];
        return $list;
    }

    /**
     * 更新为已读
     * @param array $ids
     * @return int
     */
    public function SetRead(array $ids)
    {
        return $this->NoticeCooperativeDao->UpdateNotice($ids, ['status'=>1]);
    }

}